﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace CoopSaude.Dao
{
	public class PacienteDAO
	{
		private static Pacientes.PacientesService ws;

        #region singleton
		/*implementação do singleton*/
		public static Pacientes.PacientesService Websservice
		{
			get
			{
				if (ws == null)
				{
					try
					{
                        ws = new Pacientes.PacientesService();
					}
					catch (Exception e)
					{
						throw e;
					}
				}
				return ws;
			}
		}
        #endregion

		/*reseta objeto*/
		public static void ResetWS()
		{
			ws = null;
		}

		public static Pacientes.PacienteSoap[] BuscarPaciente(string nome)
		{
            try
            {
                if (ws == null)
                {
                    try
                    {
                        ws = new Pacientes.PacientesService();
                    }
                    catch (Exception e)
                    {
                        throw e;
                    }
                }
                Pacientes.buscarPacientesResponse pacientes = ws.buscarPacientes(new Pacientes.buscarPacientes { nome = nome });
                return pacientes.buscarPacientesResult;
            }
            catch (Exception e)
            {
                ResetWS();
                throw e;
            }
            
            
		}
	}
}